﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using WebCore.Models.DataEntities;
using WebCore.Models.DataManagers;

namespace WebCore.Bases
{
    public class BaseMyPageViewModel
    {
        public string UserName { get; set; }

        private MembershipUser _CurrentMemberUser;
        public MembershipUser CurrentMemberUser
        {
            get
            {
                if (_CurrentMemberUser == null)
                    _CurrentMemberUser = System.Web.Security.Membership.GetUser(UserName);
                return _CurrentMemberUser;
            }
        }

        private User _CurrentUser;
        public User CurrentUser
        {
            get
            {
                if (_CurrentUser == null)
                    _CurrentUser = AccountManager.GetUser(CurrentUserDetail.UserID.Value);
                return _CurrentUser;
            }
        }

        private UserDetail _CurrentUserDetail;
        public UserDetail CurrentUserDetail
        {
            get
            {
                if (_CurrentUserDetail == null)
                    _CurrentUserDetail = AccountManager.GetUserDetail(UserName);
                return _CurrentUserDetail;
            }
        }
    }
}